/**
* Audio Helper files for SwakSmack Firefox Extension
* Author: clearcache@gmail.com (aka filet0fish)
*/

const AUDIO_DIR = "chrome://swaksmack/skin/";
const DEFAULT_SOUND = "swak1.wav";
//const GURU_SOUND = "question.wav";

var sound = Components.classes["@mozilla.org/sound;1"].createInstance(Components.interfaces.nsISound);
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);

function AudioManager() {
}

AudioManager.prototype.playAudioAlert = function(audioFile) {
	try {
		var enabled = SS_getPreference(SMACK_AUDIOGLOBALENABLE);
		if (enabled == false) return;
		//alert('play audioFile ' + audioFile);
		//var url = ioService.newURI(AUDIO_DIR + audioFile, null, null);
		var url = ioService.newURI(audioFile, null, null);
		sound.play(url);
		return true;
	} catch(ex) {
		alert("Playing sound failed...");
		return false;
	}
}


function playAudioAlert(audioFile){
	try {
		var enabled = SS_getPreference(SMACK_AUDIOGLOBALENABLE);
		if (enabled == false) return;
		//alert('play audioFile ' + audioFile);
		//var url = ioService.newURI(AUDIO_DIR + audioFile, null, null);
		var url = ioService.newURI(audioFile, null, null);
		sound.play(url);
		return true;
	} catch(ex) {
		alert("Playing sound failed...");
		return false;
	}
}



